[#ftl]
[#import "common/macrolibs.ftl" as lib]
[#import "common/commonclass.ftl" as cls]
${r"[#ftl]"}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>${r"[#assign module]"}[#if clazz.scopeClass??][@lib.moduleName clazz=clazz.scopeClass/]/${r"${item.scope.id}"}/[/#if][@lib.moduleNames clazz=clazz/]${r"[/#assign][#assign moduleName="}"${clazz.name}"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>[#if (item.id)??]编辑${r"${moduleName}"}信息[#else]添加新${r"${moduleName}"}[/#if]</title>
<script type="text/javascript" src="${r"${base}"}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/jquery.select.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
[#assign dateFlag=false]
[#list clazz.dynaAttributes as attr][#if (attr.type>5)&&(attr.type<9)]
[#if (!dateFlag)]
<script type="text/javascript" src="${r"${base}"}/commonjs/datepicker/WdatePicker.js"></script>
[#assign dateFlag=true]
[/#if]
[/#if][/#list]
<script type="text/javascript">
$(function(){
    [#list clazz.dynaAttributes as attr][#if !attr.carrier][#if attr.type==9]
    $("#select_${cls.myAttrNames["${attr.id}"]}").createSelect("${r"${base}"}/[@lib.moduleNames clazz=attr.refClass/]/list", {}, function(row){
        return [row.id, row.cell[1]+"["+row.cell[0]+"]"];
    },  ${r"${"}(item.${cls.myAttrNames["${attr.id}"]}.id)!0});
    [/#if][/#if][/#list]
  $("#btadditem").bind("click", function(){
    $("#additemform").ajaxForm({
      dataType: "json",
      success: function(json){
        if(!json.success){
          art.dialog.through({
            title: "${r"[#if (item.id)??]"}编辑${r"${moduleName}"}信息${r"[#else]"}添加新${r"${moduleName}"}${r"[/#if]"}失败",
            icon: "error",
            content: "${r"[#if (item.id)??]"}编辑${r"${moduleName}"}信息${r"[#else]"}添加新${r"${moduleName}"}${r"[/#if]"}失败！<br>"+json.err,
            width: 250,
            height: 150,
            background: '#EEE', // 背景色
            opacity: 0.05,  // 透明度
            lock: true,
            ok: true
          });
        }else{
          try{
             art.dialog.open.origin.flexGridReload(".flexme3");
          }catch(e){
             try{
                 art.dialog.top.frames["_iframe"].window.flexGridReload(".flexme3");
             }catch(e){
                 art.dialog.top.window.flexGridReload(".flexme3");
             }
          }
          art.dialog.close();
        }
      }
    });
  });
});
</script>
</head>
<body>
<h3>${r"[#if (item.id)??]"}编辑${r"${moduleName}"}信息${r"[#else]"}添加新${r"${moduleName}"}${r"[/#if]"}</h3>
<form id="additemform" action="${r"${base}/${module}/${((item.id)??)?string('edit','add')}"}" method="POST">
<input type="hidden" name="id" value=${r"${(item.id)!0}"}>
${r"${moduleName}"}名:<input type="text" name="name" value="${r"${(item.name)!}"}"/><br>
描述:<textarea rows="3" cols="35" name="description">${r"${(item.description)!}"}</textarea><br>
[#list clazz.dynaAttributes as attr][#if !attr.carrier][#if 
    attr.type<5]${attr.name}:<input type="text" name="${cls.myAttrNames["${attr.id}"]}" value="${r"${(item."}${cls.myAttrNames["${attr.id}"]})!}"><br>[#else][#if 
    attr.type==5]<input type="checkbox" name="${cls.myAttrNames["${attr.id}"]}" value="true" id="cb_${cls.myAttrNames["${attr.id}"]}"><label for="cb_${cls.myAttrNames["${attr.id}"]}">${attr.name}</label><br>[#else][#if 
    (attr.type>5)&&(attr.type<9)]${attr.name}:<input type="text" name="${cls.myAttrNames["${attr.id}"]}"  value="${r"${(item."}${cls.myAttrNames["${attr.id}"]}?date)!}" onfocus="WdatePicker()"/><br>[#else][#if 
    attr.type==9]${attr.name}:
<select id="select_${cls.myAttrNames["${attr.id}"]}" name="${cls.myAttrNames["${attr.id}"]}.id">
<option value="0">--请选择${attr.name}--</option>
</select><br>[/#if][/#if][/#if][/#if]
[/#if][/#list]

<input type="submit" value="[#if (item.id)??]保存${r"${moduleName}"}信息[#else]保存新${r"${moduleName}"}[/#if]" id="btadditem">
</form>
</body>
</html>